<%@ Control Language="C#" AutoEventWireup="true" Inherits="Portal.Data.Webparts.WebpartControl" %>
<%@ Import Namespace="Portal.Core" %>
<%@ Import Namespace="Portal.Data.Entity" %>

<script runat="server">
    protected override void Render(HtmlTextWriter writer)
    {
        if (Request.Url.LocalPath.IndexOf("/admin", StringComparison.OrdinalIgnoreCase) >= 0)
            return;
        Category currCat = (Session[CoreContext.SESSION_CURRENT_CAT] != null)
                               ? (Category)Session[CoreContext.SESSION_CURRENT_CAT]
                               : null;
        if (currCat == null) return;
        var parents = Category.FindParentsOnly(currCat);

        var sb = new StringBuilder();
        sb.Append("<div class='wrap_content clear_fix " + Config.ClassName + "'>");
        sb.Append("<ol class='nav'>");
        for (int i = 0; i < parents.Count; i++)
        {
            var cat = (Category)parents[i];
            sb.Append(string.Format("<li><a href=\"{0}\" title='{1}' class='{2}'>{1}</a></li>", cat.Url, cat.FullName, cat.ID == currCat.ID ? "end" : ""));
        }
        sb.Append("</ol></div>");

        writer.Write(sb.ToString());
    }
</script>